<template>
  <div id="app">
    <div class="box">
      <form>
        <label for="username">用户名：</label><br />
        <input
          type="text"
          name="username"
          v-model="uName"
          id="username"
        /><br />
        <label for="password">密码：</label><br />
        <input type="password" v-model="pwd" name="pwd" id="password" /><br />
        <input type="button" value="登录" @click="submitForm" />
        <a href="#/reg"><input type="button" value="注册"/></a>
      </form>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      uName: "",
      pwd: "",
    };
  },
  methods: {
    submitForm: function () {
      let url = "/loginServlet";
      let params = `username=${this.uName}&pwd=${this.pwd}`;
      this.$axios.post(url, params).then((resp) => {
        console.log(resp.data)
        if (resp.data) {
          location.href="#/hello"
          
        } else {
          alert("登录失败")
        }
      });
    },
  },
};
</script>

<style>
</style>